package com.ld.poetry.controller;

import com.ld.poetry.service.impl.TestCacheService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;

import static java.lang.Thread.sleep;

/**
 * 新增功能，缓存测试
 * created by vital on 2024/12/8 下午12:33
 */
@RestController
public class TestCacheController {

    @Resource
    private TestCacheService testCacheService;


    @GetMapping("/")
    public String test(){
        return "ok:"+ LocalDateTime.now();
    }

    @GetMapping("/test/cache")
    String testCache(String key,long timeout){
        System.out.println("testCache:"+key);
        try {
            testCacheService.timeoutTask(key,timeout);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        return key;
    }

}
